# 单无人机 FARM 南瓜

from utils import *
clear()

set_world_size(6)
l = get_world_size()


# 设置 世界实际尺寸 和 FARM 区域的 坐标, 并开始 FARM
def set_area_and_start(worldsize=l,x0=0,y0=0,x1=l-1,y1=l-1):
    map = []
    
    def action(x,y):
        if get_ground_type() != Grounds.Soil:
            till()
        map.append((x,y))
        plant(Entities.Pumpkin)
        pourwater(.75)

    while 1:
        snake_traverse(worldsize,x0,y0,x1,y1,action)
        while 1:
            growing_map = []
            for pos in map:
                goto(l,pos[0],pos[1])
                if not can_harvest():
                    plant(Entities.Pumpkin)
                    growing_map.append(pos)
            map = growing_map
            if len(map) == 0:
                harvest()
                break
            
           
set_area_and_start(l)